Let’s load the AirBnB dataset.
data("nyc_airbnb")
nyc_airbnb =
nyc_airbnb |>
mutate(
rating = review_scores_location / 2
) |>
select(
neighbourhood_group, neighbourhood, rating,
price, room_type, lat, long
) |>
filter(
neighbourhood_group == "Manhattan",
room_type == "Entire home/apt",
price <= 500,
price >= 100
)
Let’s make a scatterplot!! But interactive this time.
nyc_airbnb |>
mutate(
label = str_c("Price: $",price, "\nRating: ",rating)
) |>
plot_ly(
x = ~lat, y = ~long, color = ~price,
text = ~ label,
type = "scatter", mode = "markers", alpha = 0.5
)